"use strict";
var loading = !1
  , app = new Vue({
    el: "#app",
    data: {
        itabs: [{
            name: "八卦",
            type: 1
        }, {
            name: "散文",
            type: 2
        }, {
            name: "杂谈",
            type: 3
        }],
        tabs: [{
            name: "全部时间",
            id: 0
        }, {
            name: "最近一月",
            id: 1
        }],
        tabContents: [],
        num: 0,
        num2: 0,
        listTab: [],
        Type: 0,
        hideing: !0,
        types: 1,
        pageIndex: 1,
        pageSize: 10,
        userId: 0,
        cityId: 0
    },
    created: function() {
        if ("" != $.getPara("userId")) {
            var t = $.getPara("userId");
            this.userId = t,
            $.setStorage("userId", t)
        } else if ($.getStorage("userId") && "" != $.getStorage("userId")) {
            t = parseInt($.getStorage("userId"));
            this.userId = t
        }
        $.getPara("types") && (this.types = $.getPara("types")),
        "" != $.getPara("cityId") && (this.cityId = $.getPara("cityId")),
        console.log(this.cityId)
        this.getList()
    },
    mounted: function() {
        var e = this;
        this.$nextTick(function() {
            $(document.body).infinite().on("infinite", function() {
                loading || (loading = !0,
                e.hideing = !1,
                setTimeout(function() {
                    var t = e.pageIndex;
                    t++,
                    e.pageIndex = t,
                    e.getList(),
                    loading = !1
                }, 1500))
            })
        })
    },
    methods: {
        getList: function() {
            var n = this;
            $.ajax({
                url: "/api/mood/substationList",
                type: "get",
                dataType: "json",
                data: {
                    cityId: n.cityId,
                    type: n.types,
                    timeType: n.Type,
                    pageIndex: n.pageIndex,
                    pageSize: n.pageSize
                },
                success: function(t, e, i) {
                    if (200 == t.code) {
                        var s = t.data.list;
                        if (0 < s.length) {
                            var a = n.listTab.concat(s);
                            n.listTab = a
                        } else
                            loading = !0,
                            $.toast("暂无数据", "text");
                        n.hideing = !0
                    }
                },
                error: function() {
                    $.toast("加载失败，请重试", "text")
                }
            })
        },
        tab: function(t) {
            t != this.types && (this.types = t,
            this.Type = 0,
            this.pageIndex = 1,
            this.listTab = [],
            this.getList())
        },
        tab2: function(t) {
            t != this.Type && (this.Type = t,
            this.pageIndex = 1,
            this.listTab = [],
            this.getList())
        },
        urlHref: function(t) {
            var e = {
                title: "心情详情",
                type: "dynamic"
            };
            e.url = "/PageClassify/html/Substation/Dynamic/mooddetail.html?id=" + t.id + "&types=" + this.types+"&cityId="+this.cityId,
            0 < this.userId && (e.url = "/PageClassify/html/Substation/Dynamic/mooddetail.html?id=" + t.id + "&userId=" + this.userId + "&types=" + this.types+"&cityId="+this.cityId),
            /(Android)/i.test(navigator.userAgent) ? jsAndroid.appPush(JSON.stringify(e)) : /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent) ? window.webkit.messageHandlers.appPush.postMessage(e) : window.location.href = e.url
        }
    }
});
